package ollama.ai.three.controller;

import jakarta.annotation.Resource;
import ollama.ai.three.service.ChatMemoryService;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;


/**
 * @Auther:Liu
 * @Testname:ChatMemoryController
 * @Date:2025/9/23 11:45
 */
@RestController
@RequestMapping("/ollama_ai_memory")
public class ChatMemoryController {
    @Resource
    private ChatMemoryService chatMemoryService;

    /**
     * 用户聊天方法
     * @param role
     * @param question
     * @return
     */
    @GetMapping(value = "/stream", produces = "text/html;charset=utf-8")
    Flux<String> stream(@RequestParam(value = "role", required = false, defaultValue = "user") String role, 
                        @RequestParam("question") String question) {
        return chatMemoryService.getMessage(role, question);
    }


}
